package org.box.demos.multithreading.wgetmt.j16mt;

import org.box.demos.multithreading.wgetmt.core.URL;

/**
 * A listener for {@link TaskManager}'s events
 * 
 * @author <a href="mailto:alexander.box@gmail.com">Alexander Korobka</a>
 *
 */
public interface TaskManagerListener {

	/**
	 * Fires on successful task completion
	 * 
	 * @param result - an aggregated result of the task exception
	 * @param remains - a number of requested urls that remains to download
	 */
	void onTaskCompleted(TaskResult result, int remains);

	/**
	 * Fires on skip task completion
	 * 
	 * @param result - an aggregated result of the task exception
	 * @param remains - a number of requested urls that remains to download
	 */
	void onTaskSkipped(TaskResult result, int remainsNumber);
	
	/**
	 * Fires on unsuccessful task completion
	 * 
	 * @param groupId - id of the requested url or urls' group
	 * 
	 * @param url - the requested url
	 * 
	 * @param e - the root cause of the failure
	 */
	void onTaskFailed(String groupId, URL url, Throwable e);

}
